﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ImagePrint
{
    public partial class Form1 : Form
    {
        PrintDirectClass pdc = new PrintDirectClass();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnB_Click(object sender, EventArgs e)
        {
            //fBD.SelectedPath = System.IO.Directory.GetCurrentDirectory();
            fBD.SelectedPath = "D:\\文档系统\\";
            if (fBD.ShowDialog() == DialogResult.OK)
            {
                
                txtpath.Text = fBD.SelectedPath;
                string result = FindAllDir(fBD.SelectedPath);
                textBoxResult.Text = result + "\r\n";

            }
        }
        string result = "";

        public string FindAllDir(string FilePath)
        {

            try
            {
                DirectoryInfo di = new DirectoryInfo(FilePath);
                DirectoryInfo[] dis = di.GetDirectories();
                FileInfo[] fi = di.GetFiles();
                foreach (FileInfo fiInfo in fi)
                {
                    result += fiInfo.FullName + "\r\n";
                    pdc.fileList.Add(fiInfo.FullName);

                }

                foreach (DirectoryInfo diInfo in dis)
                {                   
                    FindAllDir(diInfo.FullName);
                }               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return result;
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {            
            pdc.PrintPreview();
        }
    }
}
    